package com.cheer.dto;

import com.cheer.entity.Account;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author cheer
 */
@Data
@Accessors(chain = true)
public class AccountDTO {

    private String phone;

    private String backupAccount;

    private String password;

    private Integer role;

    private String securityQuestion;

    private String securityAnswer;

    public Account build(PasswordEncoder passwordEncoder) {
        Account account = new Account();
        account.setPhone(phone);
        account.setBackupAccount(backupAccount);
        account.setPassword(passwordEncoder.encode(password));
        account.setRole(role);
        account.setSecurityQuestion(securityQuestion);
        account.setSecurityAnswer(securityAnswer);
        return account;
    }
}
